package com.funny.test.aop;

import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author fanxiao  2022/2/15
 * @since 1.0.0
 */
@Configuration
public class AppConfig {


	@Bean("simplePojo")
	public SimplePojo simplePojo() {
		return new SimplePojo();
	}

	@Bean("proxy")
	public ProxyFactoryBean proxyFactoryBean() throws ClassNotFoundException {
		ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
		proxyFactoryBean.setProxyInterfaces(new Class[]{Pojo.class});
		proxyFactoryBean.setTargetName("simplePojo");
		proxyFactoryBean.setInterceptorNames("proxyMethodBeforeAdvice");
		proxyFactoryBean.setExposeProxy(true);
		return proxyFactoryBean;
	}

	@Bean("proxyMethodBeforeAdvice")
	public ProxyMethodBeforeAdvice proxyMethodBeforeAdvice() {
		return new ProxyMethodBeforeAdvice();
	}
}